package com.longfa.ojbackendjudgeservice.codesandbox;

import com.longfa.ojbackendjudgeservice.codesandbox.impl.ExampleCodeSandbox;
import com.longfa.ojbackendjudgeservice.codesandbox.impl.RemoteCodeSandbox;
import com.longfa.ojbackendjudgeservice.codesandbox.impl.ThirdPartyCodeSandbox;

/**
 * ClassName: CodeSandboxFactory
 * Package: com.fa.oj.judge.codesandbox
 * Description: 代码沙箱工厂（根据字符串参数创建指定的代码沙箱实例）   这里采用 静态工厂模式
 *
 * @Author:
 * @Create: 2024/4/23 - 15:32
 * @Version: v1.0
 */
public class CodeSandboxFactory {

    public static CodeSandbox newInstance(String type) {
        switch (type) {
            case "example":
                return new ExampleCodeSandbox();
            case "remote":
                return new RemoteCodeSandbox();
            case "thirdParty":
                return new ThirdPartyCodeSandbox();
            default:
                return new ExampleCodeSandbox();
        }
    }
}
